package wsh;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Scanner;

/*
编写程序，(Scanner)当以年-月-日的格式输入一个日期时，输出其该年是否为闰年，该月有几天，该日是星期几
 */
public class Fruo {

    public static void main(String[] args) throws ParseException {

        Scanner scanner=new Scanner(System.in);

        System.out.println("请输入年月份(以-年-月-日的格式输入)：");

        String string=scanner.nextLine();

        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日");

        Date date=simpleDateFormat.parse(string);

        Calendar calendar=Calendar.getInstance();

        calendar.setTime(date);

        int year=calendar.get(Calendar.YEAR);

        int week=calendar.get(Calendar.DAY_OF_WEEK)-1;

        GregorianCalendar gregorianCalendar=new GregorianCalendar();

        if (gregorianCalendar.isLeapYear(year)){

            System.out.println(year+"是闰年");
        }else{
            System.out.println(year+"不是闰年");
        }

        int num=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

        System.out.println("该月有"+num+"天，该日是周"+week);

    }
}
